home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctjjl86.arc
/
ANIMATE.ARC
/
BYTEMOV.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-04-16
|
5KB
|
146 lines
; *** Listing 8 ***
;
;Byte-move graphics driver for putting rectangular images into
; the Color/Graphics Adapter's medium-resolution memory map.
;
; Note: AX,BX,CX,DX,BP,SI,DI destroyed.
;
one segment para public 'CODE'
assume cs:one,ds:one,es:nothing
public form_driver,erase_form_driver
;
form_driver proc near
mov di,[bx+even_line_screen_offset_table] ;find the
; offset of the top line of image
add di,cx ;ES:DI now points to byte at which to put
; the image's upper left corner
lodsb ;get the height of the image
xor ah,ah ;make height a word value for calculations
mov bx,ax ;store height in BX
lodsb ;get the width of the image in bytes
mov bp,2000h ;calculate the amount to add after even scan
sub bp,ax ; lines are drawn to get to the address of
; the next scan line
mov dx,1fb0h ;calculate the amount to subtract after odd
add dx,ax ; scan lines are drawn to get to the address
; of the next scan line
jmp [bx+inline_height_vector_table-2] ;-2 because there
; is no 0 lines entry point
;
;This table is used to find the offset of an even scan line in
; the memory map of the color graphics adapter in medium res mode.
;
even_line_screen_offset_table label word
x=0
rept 100 ;there are 100 even lines
dw x*50h ; each is 50h (80 decimal) long
x=x+1
endm
;
;This is inline code for moving the image into the screen memory map.
;
label macro x ;this macro is used to label the inline code
line&x&: ; entry points
endm
;
x=42 ;there will be an entry point for each even
; number of lines between 2 and 40. They will
; be labeled "line2", "line4", ... "line40"
rept 20
x=x-2 ;calculate no. of lines for this entry point
label %x ;put in label for entry point
mov cx,ax ;put width of image in bytes in CX to prepare
rep movsb ; for repeated move string on even line
add di,bp ;calc addr. of next line: DI + (2000h-width)
mov cx,ax ;put width of image in bytes in CX to prepare
rep movsb ; for repeated move string on odd line
sub di,dx ;calc addr. of next line: DI - (1fb0h+width)
endm
ret
;
;This table is used as an indirect address for jumping into
; the inline code for image moving.
;
inline_height_vector_table label word ;there is no entry point for
; 0 lines. Starting at 2 eliminates
; the need to store a dummy entry
; point address
entry_address macro x ;this macro is used to generate
dw line&x& ; the labels corresponding to the
endm ; inline code entry points
;
x=2
rept 20
entry_address %x
x=x+2
endm
;
form_driver endp
;
;Byte-move graphics driver for erasing rectangular areas of
; the Color/Graphics Adapter's medium-resolution memory map.
;
; Note: AX,BX,CX,DX,BP,SI,DI destroyed.
;
erase_form_driver proc near
mov di,[bx+even_line_screen_offset_table] ;find the
; offset of top line of image
add di,cx ;ES:DI now points to byte at which to put
; the image's upper left corner
lodsb ;get the height of the image
xor ah,ah ;make height a word value for calculations
mov bx,ax ;store height in BX
lodsb ;get the width of the image in bytes
mov bp,2000h ;calculate the amount to add after even scan
sub bp,ax ; lines are drawn to get to the address of
; the next scan line
mov dx,1fb0h ;calculate the amount to subtract after odd
add dx,ax ; scan lines are drawn to get to the address
; of the next scan line
mov si,ax ;save width in SI for this erase driver
mov al,ah ;zero AL (data to blank with)
jmp [bx+erase_height_vector_table-2] ;-2 because there is
; no 0 lines entry point
;
;This is inline code for erasing the image from the screen memory map.
;
elabel macro x ;this macro is used to label the inline code
eline&x&: ; entry points
endm
;
x=42 ;there will be an entry point for each even
; number of lines between 2 and 40. They will
; be labeled "eline2", "eline4", ... "eline40"
rept 20
x=x-2 ;calc number of lines for this entry point
elabel %x ;put in label for entry point
mov cx,si ;put width of image in bytes in CX to prepare
rep stosb ; for repeated store string instruction
add di,bp ;calc address of next line DI + (2000h-width)
mov cx,si ;put width of image in bytes in CX to prepare
rep stosb ; for repeated store string instruction
sub di,dx ;calc address of next line DI - (1fb0h+width)
endm
ret
;
;This table is used as an indirect address for jumping into
; the inline code for image erasing.
;
erase_height_vector_table label word ;there is no entry point for
; 0 lines. Starting at 2
; eliminates the need to store
; a dummy entry point address
erase_entry_address macro x ;this macro is used to generate
dw eline&x& ; the labels corresponding to the
endm ; inline code entry points
;
x=2
rept 20
erase_entry_address %x
x=x+2
endm
;
erase_form_driver endp
one ends
end